const gulp = require('gulp')
const cssmin = require('gulp-cssmin')
const autoprefixer = require('gulp-autoprefixer')
const uglify = require('gulp-uglify')
const babel = require('gulp-babel')
const htmlmin = require('gulp-htmlmin')
const fileinclude = require('gulp-file-include')

function cssHandler(){
    return  gulp
    .src('./src/meizu/css/*.css')
    .pipe(autoprefixer())
    .pipe(cssmin())
    .pipe(gulp.dest('./dist/css/'))
}
function jsHandler(){
    return  gulp
    .src('./src/meizu/js/*.js')
    .pipe(babel({presets:['@babel/preset-env']}))
    .pipe(uglify())
    .pipe(gulp.dest('./dist/js/'))
}
function htmlHandler(){
    return  gulp
    .src('./src/meizu/*.html')
      .pipe(htmlmin({ 
        collapseWhitespace: true,
        removeAttributeQuotes: true,
        removeEmptyAttributes: true,
        removeComments: true,
        removeScriptTypeAttributes: true,
        removeStyleLinkTypeAttributes: true,
        collapseBooleanAttributes: true,
        minifyJS: true,
        minifyCSS: true
      }))
    .pipe(gulp.dest('./dist/'))
}
const _default = gulp.parallel(
    (cssHandler,jsHandler, htmlHandler)
    )
module.exports = {
    cssHandler,
    jsHandler,
    htmlHandler,
    default:_default
}  